package com.binfenhulian.chinaenergy.ces.manage.core.url2io.bean.enums;

import lombok.Data;

/**
 * Created by wanghjbuf on 2018/3/15.
 */
public enum ResponseErrorEnum {

    PERMISSION_ERROR("PermissionError", "Token认证错误；已超出使用配额"),
    HTTP_ERROR("HTTPError", "抓取需要提取正文的网页时发生HTTP请求错误，如：404 Not Found"),
    URL_ERROR("URLError", "抓取需要提取正文的网页时发生网址错误，如：Name or service not known"),
    TYPE_ERROR("TypeError", "请求的资源不是html文档或xhtml文档，无法提取正文"),
    UN_KNOW_ERROR("UnknowError", "未知错误，很可能是服务器内部错误。具体看错误消息");

    private String errorKey;
    private String errorRemark;

    ResponseErrorEnum(String errorKey, String errorRemark) {
        this.errorKey = errorKey;
        this.errorRemark = errorRemark;
    }

    public static ResponseErrorEnum getResponseErrorEnumByErrorKey(String errorKey) {
        ResponseErrorEnum[] valueEnums = ResponseErrorEnum.values();
        for (int i = 0; i < valueEnums.length; i++) {
            if (errorKey.equals(valueEnums[i].errorKey)) {
                return valueEnums[i];
            }
        }
        return null;
    }

    public String getErrorKey() {
        return errorKey;
    }

    public String getErrorRemark() {
        return errorRemark;
    }
}
